package com.cxwx.bootmybaties.service;

import com.cxwx.bootmybaties.dao.BookMapper;
import com.cxwx.bootmybaties.entity.Book;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookService {

    @Autowired
    BookMapper bookMapper;

    public List<Book> getAll() {
        return bookMapper.selectList();
    }

    public PageInfo<Book> getPage(Integer pageNum) {
        PageHelper.startPage(pageNum, 3);
        List<Book> books = bookMapper.selectList();
        return new PageInfo<>(books);
    }

    public void del(Integer[] ids) {
        bookMapper.del(ids);
    }
}
